/*
 * @Description: 
 * @Author: zhuying
 * @Date: 2024-11-07 10:37:51
 * @LastEditors: rendc
 * @LastEditTime: 2024-11-07 11:23:38
 */
var arr=new Array(1,2,3);
var arr1=[1,2,3];
console.log('🚀 - arr1=[0]:', arr1=[0])
console.log('🚀 - arr.length:', arr.length)
arr[10]=10;
console.log('🚀  - arr[9]:', arr[9]);
console.log('🚀  - arr[10]:', arr[10]);
console.log('🚀 - arr.length:', arr.length)

//追加元素
arr.push('a','b');
//删除元素 索引开始位置 删除元素的个数
arr.splice(0,2);
//遍历数组
for(var i=0;i<arr.length;i++){
    console.log('arr['+i+']:'+arr[i])
}
// arr.forEach(
//     function(item){
// console.log('🚀 - arr.forEach - item:', item)
// }
// )

arr.forEach(
    // 箭头函数
    item=>{
    console.log('🚀 =>item:', item);
})


// var fun1=function(item){
//     console.log('🚀 - fun1 - item:', item)
// }
// arr.forEach(fun1);

var str=new String("Hello");
console.log('🚀 - str:', str)
console.log('🚀 - str.length:', str.length)
var str2=new String("Hello");
console.log('🚀 - str2:', str2)
console.log('🚀 - str2.length:', str2.length)
var stu1={
    //属性
    name:"s1",
    age:18,
    gender:"女",
    likes:["音乐","游戏"],
    //方法
    eat:function(){
        console.log("公主请吃饭");
    }

}
console.log('🚀 - stu1.name:', stu1.name)
stu1.eat();


